/*
package com.ruiyian.common.kafka;

import com.ruiyian.framework.config.ServerConfig;
import com.ruiyian.project.event.service.IEventRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

*/
/**
 * 消息的消费者
 *//*

@Slf4j
@Component
public class KafkaReceiver {

    @Autowired
    private IEventRecordService eventRecordService;

    @Autowired
    private ServerConfig serverConfig;

    */
/*@KafkaListener(topics = {"${kafka.topic.event_topic}"})
    public void listen1(ConsumerRecord<?, ?> record) {
        Optional<?> kafkaMessage = Optional.ofNullable(record.value());
        if (kafkaMessage.isPresent()) {
            Object message = kafkaMessage.get();
            JSONObject jsonObject = JSONObject.parseObject(message.toString());
            if (null != jsonObject) {
                EventRecord eventRecord = JSONObject.toJavaObject(jsonObject, EventRecord.class);
                try {
                    String imgUrl = eventRecord.getImgUrl();
                    if (StringUtils.isNotEmpty(imgUrl)){
                        String[] uploadPaths = imgUrl.split("uploadPath");
                        String imgUrlNew = RuiyianConfig.getAddress() + uploadPaths[1];
                        eventRecord.setImgUrl(imgUrlNew);
                    }
                    String videoUrl = eventRecord.getVideoUrl();
                    if (StringUtils.isNotEmpty(videoUrl)){
                        String[] uploadPaths = videoUrl.split("uploadPath");
                        String videoUrlNew = RuiyianConfig.getAddress() + uploadPaths[1];
                        eventRecord.setVideoUrl(videoUrlNew);
                    }
                    eventRecordService.insertEventRecord(eventRecord);
                    //通知 所有登录首页的用户
                    WebSocketUsers.sendMessageToUsersByText("true");
                } catch (Exception e) {
                    log.info(e.getMessage());
                }
            }
            log.info("kafka事件监测消息：{}", message);
            log.info("----------------- record =" + record);
        }

    }*//*


}
*/
